package com.t216.dm216.common;

import lombok.Data;

@Data
public class Result<T> {
    private String success;
    private String errorCode;
    private String msg;
    private T data;

    private Result() {
    }

    private Result(String success, String errorCode, String msg, T data) {
        this.success = success;
        this.errorCode = errorCode;
        this.msg = msg;
        this.data = data;
    }

    public static <T> Result<T> success() {
        return new Result<>("0000","0000","成功",null);
    }
    public static <T> Result<T> success(T data) {
        return new Result<>("0000","0000","成功",data);
    }

    public static <T> Result<T> success(String msg,T data) {
        return new Result<>("0000","0000",msg,data);
    }




    public static <T> Result<T> error(String errorCode) {
        return new Result<>(errorCode,errorCode,null,null);
    }

    public static <T> Result<T> error(String errorCode,String msg) {
        return new Result<>(errorCode,errorCode,msg,null);
    }
}
